{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import sys"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Point estimates"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Completeness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_list = [\n",
    "    'cpt_a',\n",
    "    'cpt_d',\n",
    "    'cpt_g',\n",
    "    'cpt_ad',\n",
    "    'cpt_ag',\n",
    "    'cpt_dg',\n",
    "    'cpt_adg',\n",
    "    'da_a',\n",
    "    'da_e',\n",
    "    'da_ae'\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPT(alpha)\n",
      "\n",
      "completeness: 0.2509471302832519\n",
      "\n",
      "model_best_param: [0.761 1.    1.   ]\n",
      "\n",
      "CPT(delta)\n",
      "\n",
      "completeness: 0.27657917231807894\n",
      "\n",
      "model_best_param: [1.  1.  0.7]\n",
      "\n",
      "CPT(gamma)\n",
      "\n",
      "completeness: 0.6907663416984305\n",
      "\n",
      "model_best_param: [1.    0.442 1.   ]\n",
      "\n",
      "CPT(alpha, delta)\n",
      "\n",
      "completeness: 0.2675062038621774\n",
      "\n",
      "model_best_param: [0.984 1.    0.7  ]\n",
      "\n",
      "CPT(alpha, gamma)\n",
      "\n",
      "completeness: 0.9828411772124657\n",
      "\n",
      "model_best_param: [0.77  0.416 1.   ]\n",
      "\n",
      "CPT(delta, gamma)\n",
      "\n",
      "completeness: 0.9414144352968021\n",
      "\n",
      "model_best_param: [1.    0.403 0.71 ]\n",
      "\n",
      "CPT(alpha, delta, gamma)\n",
      "\n",
      "completeness: 0.9789148342373843\n",
      "\n",
      "model_best_param: [0.776 0.415 0.99 ]\n",
      "\n",
      "DA(alpha)\n",
      "\n",
      "completeness: 0.2509471302832519\n",
      "\n",
      "model_best_param: [0.761 0.   ]\n",
      "\n",
      "DA(eta)\n",
      "\n",
      "completeness: 0.26484630229704953\n",
      "\n",
      "model_best_param: [1.    0.474]\n",
      "\n",
      "DA(alpha, eta)\n",
      "\n",
      "completeness: 0.26484630229704953\n",
      "\n",
      "model_best_param: [1.    0.474]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for model in model_list:\n",
    "    filename = './job_scripts_comp/outlog_' + model\n",
    "    with open(filename, 'r', encoding='utf-8') as fin:\n",
    "        for i, line in enumerate(fin.readlines()):\n",
    "            if i==0 or i==2 or i==4:\n",
    "                print(line)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Restrictiveness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cpt_a\n",
      "restrictiveness: 0.9411588540078235\n",
      "\n",
      "stderr: 0.004185148500095197\n",
      "\n",
      "cpt_d\n",
      "restrictiveness: 0.6726125018251018\n",
      "\n",
      "stderr: 0.009666468489341688\n",
      "\n",
      "cpt_g\n",
      "restrictiveness: 0.540742951592534\n",
      "\n",
      "stderr: 0.005558364831393173\n",
      "\n",
      "cpt_ad\n",
      "restrictiveness: 0.41683227919570265\n",
      "\n",
      "stderr: 0.0044284153188034\n",
      "\n",
      "cpt_ag\n",
      "restrictiveness: 0.49081245496562526\n",
      "\n",
      "stderr: 0.0058824259469597165\n",
      "\n",
      "cpt_dg\n",
      "restrictiveness: 0.3316104024163747\n",
      "\n",
      "stderr: 0.0037159901309124703\n",
      "\n",
      "cpt_adg\n",
      "da_a\n",
      "restrictiveness: 0.9411588540078235\n",
      "\n",
      "stderr: 0.004185148500095197\n",
      "\n",
      "da_e\n",
      "restrictiveness: 0.6720670481744617\n",
      "\n",
      "stderr: 0.009686621417758147\n",
      "\n",
      "da_ae\n",
      "restrictiveness: 0.38303100873956086\n",
      "\n",
      "stderr: 0.004754762846946673\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for model in model_list:\n",
    "    filename = './job_scripts_rest/outlog_' + model\n",
    "    with open(filename, 'r', encoding='utf-8') as fin:\n",
    "        print(model)\n",
    "        for i, line in enumerate(fin.readlines()):\n",
    "            print(line)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Bootstrap SE (Completeness)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bs_cpt_a: 0.057256845224377136\n",
      "bs_cpt_d: 0.05757073304808926\n",
      "bs_cpt_g: 0.05966694461464216\n",
      "bs_cpt_ad: 0.05681028892083537\n",
      "bs_cpt_ag: 0.010356384433964388\n",
      "bs_cpt_dg: 0.026167734262423765\n",
      "bs_cpt_adg: 0.01002200214458256\n",
      "bs_da_a: 0.11365411969095929\n",
      "bs_da_e: 0.05773844213892\n",
      "bs_da_ae: 0.06049887504943963\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "\n",
    "model_list = [\n",
    "    'bs_cpt_a',\n",
    "    'bs_cpt_d',\n",
    "    'bs_cpt_g',\n",
    "    'bs_cpt_ad',\n",
    "    'bs_cpt_ag',\n",
    "    'bs_cpt_dg',\n",
    "    'bs_cpt_adg',\n",
    "    'bs_da_a',\n",
    "    'bs_da_e',\n",
    "    'bs_da_ae'\n",
    "]\n",
    "\n",
    "for model in model_list:\n",
    "    nums = []\n",
    "    for iter in range(1000):\n",
    "        filename = './bootstrap/' + model + '_{}.out'.format(iter)\n",
    "        with open(filename, 'r', encoding='utf-8') as fin:\n",
    "            for line in fin.readlines():\n",
    "                try:\n",
    "                    num = float(line)\n",
    "                except ValueError as e:\n",
    "                    print(e, file=sys.stderr)\n",
    "                    continue\n",
    "                nums.append(num)\n",
    "    arr = np.array(nums)\n",
    "    stderr = np.sqrt(np.var(arr))\n",
    "    print(model + ': {}'.format(stderr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
